var tpl = `<div>{{ name + sex + 'hello!' }}</div>`;
var data = {name: 'joker', sex: 'male'};

var tmpl = function(tpl, data) {
    return tpl.replace(/\{\{(.*)\}\}/g, function(match, p1) {
        // p1: `  name + sex + 'hello!' `
        return p1.split(/[\s+]+/)
            //split result: ["", "name", "sex", "'hello!", ""]
            .map(item => {
                if (!/['"]/.test(item)) {
                    // when item = "name", "sex"
                    return data[item] || ''
                } else if (item) {
                    // when item = "'hello!"
                    return item.replace(/['"]/g,'')
                }
                return item
        }).join('')
    })
}

console.log(tmpl(tpl, data)); // output: <div>jokermalehello!</div>